import { ref, onMounted } from "vue";
import * as vant from "vant";
const { showFailToast, showSuccessToast } = vant;
export const useRequest = () => {
  let messageList = ref([]);
  const userInfo = localStorage.getItem("userInfo") as string;
  const userInfoJSON = JSON.parse(userInfo) as any;
  onMounted(() => {
    getMessageList();
  });
  const getMessageList = () => {
    (window as any).timTool
      .getMessageList({
        userID: userInfoJSON.phone || "",
        to: "",
        templateId: "287a53aa61aed3d900d4a9091f69dce0",
        appid: "1400804218",
      })
      .then((res: any) => {
        let list: any = [];
        let lst = res.data.conversationList;
        console.log("开始打印aaaaaalst", res);
        console.log("开始打印aaaaaalst", lst);
        lst.map((item: any) => {
          // let nowtime = Math.ceil(Date.now() / 1000);
          // let dirrTime = Math.ceil((nowtime - item.lastMessage.lastTime) / 60);
          // if (item.unreadCount == 0 && dirrTime > 10) {
          //     list.push(item);
          // }
          list.push(item);
        });
        messageList.value = list;
      });
  };
  return {
    messageList,
  };
};
